package com.ibeeking.found.org.b.rest.controller.v1;

import com.ibeeking.found.org.b.rest.service.IEmployeeFieldService;
import com.ibeeking.found.org.service.common.param.EmployeeFieldParam;
import com.ibeeking.found.org.service.common.param.EmployeeFieldSwitchParam;
import com.ibeeking.found.org.service.common.query.EmployeeFieldPageQuery;
import com.ibeeking.found.org.service.common.vo.EmployeeFieldVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName MemberInfoFieldController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-01-24 11:39
 **/
@RestController
@RequestMapping("/b/extendField/v1")
public class EmployeeFieldController {

    @Resource
    private IEmployeeFieldService employeeFieldServiceImpl;

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "增加员工资料字段")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) EmployeeFieldParam memberInfoFieldParam) {
        return employeeFieldServiceImpl.add(memberInfoFieldParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改员工资料字段")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) EmployeeFieldParam param) {
        return employeeFieldServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改员工资料字段是否必填,是否可修改,是否显示")
    @PostMapping(value = "/modify/switch")
    public Boolean modifySwitch(@RequestBody @Validated() EmployeeFieldSwitchParam param) {
        return employeeFieldServiceImpl.modifySwitch(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "员工资料字段分页列表")
    @PostMapping(value = "/pageList")
    public Page<EmployeeFieldVO> pageList(@RequestBody EmployeeFieldPageQuery pageQuery) {
        return employeeFieldServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看员工资料字段")
    @GetMapping(value = "/view/{id}")
    public EmployeeFieldVO view(@PathVariable("id") Long id) {
        return employeeFieldServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除员工资料字段")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return employeeFieldServiceImpl.del(id);
    }
}
